< previous page page_76 next page >

Page 76
0076-01.jpg
Figure 2.14
Program FillMode demonstrates polygon fill modes.
FloodFill
The FloodFill function fills an area of the screen using the current brush. The fill begins at the point (X, Y) and continues in all directions until the function encounters a pixel with the color crColor. At that point, the function stops filling in that direction. The following code shows how to declare the FloodFill function in Visual Basic.
e10a6a0a59f035e870d90cca05b85fce.gif
Private Declare Function FloodFill Lib "gdi32" _
    Alias "FloodFill' (ByVal hdc  As Long, _
    ByVal x As Long, ByVal y As Long, _
    ByVal crColor As Long) As Long
Example program Flood, shown in Figure 2.15, demonstrates the FloodFill API function. When you click on the form, the program fills the area you clicked using a random color.
The ExtFloodFill function is similar to FloodFill except it takes an extra parameter that determines how the fill progresses. If you set the wFillType parameter to FLOODFILLBORDER, the fill stops when it finds a pixel with color crColor (exactly as before). If you set wFillType to FLOODFILLSURFACE, the fill continues as long as the function finds pixels that do have the specified color rather than as long as they do not have that color. This approach can be useful when you want to fill an object that has a single color but that has a multicolored boundary.
e10a6a0a59f035e870d90cca05b85fce.gif
Private Const FLOODFILLBORDER = 0
Private Const FLOODFILLSURFACE = 1

Private Declare Function ExtFloodFill Lib "gdi32" _
    Alias "ExtFloodFill" (ByVal hdc As Long, _

 
< previous page page_76 next page >